package Thread;

import java.util.ArrayList;


public class subAlgo extends Thread{
	public algo tot;
	public subAlgo(algo tot) {
		super();
		this.tot=tot;
	}

	synchronized public void sround() throws InterruptedException {
		int i;
		ArrayList <subsubalgo> round = new ArrayList<subsubalgo>(tot.nSteps);
		ArrayList <Thread> t = new ArrayList <Thread>(tot.nSteps);
		tot.St=tot.S;
		for(i=0;i<tot.nSteps;i++){
			round.add(new subsubalgo(tot));
			t.add(new Thread(round.get(i)));
			t.get(i).start();
		}for(i=0;i<tot.nSteps;i++) t.get(i).join();
		tot.Sum=tot.Sum + java.lang.Math.max((tot.z*(tot.St-tot.X)),0);
	}
	
	

	@Override
	public void run() {
		try {
			sround();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}		
	}

}
